package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Sebas
 */
@Entity
@Table(name = "soundtrack")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Soundtrack.findAll", query = "SELECT s FROM Soundtrack s"),
    @NamedQuery(name = "Soundtrack.findByIdSountrack", query = "SELECT s FROM Soundtrack s WHERE s.idSountrack = :idSountrack")})
public class Soundtrack implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id_sountrack")
    private Integer idSountrack;
    @Basic(optional = false)
    @Lob
    @Column(name = "sound_picture")
    private String soundPicture;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "soundtrackIdSountrack")
    private Collection<Song> songCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "soundtrackIdSountrack")
    private Collection<Movie> movieCollection;

    public Soundtrack() {
    }

    public Soundtrack(Integer idSountrack) {
        this.idSountrack = idSountrack;
    }

    public Soundtrack(Integer idSountrack, String soundPicture) {
        this.idSountrack = idSountrack;
        this.soundPicture = soundPicture;
    }

    public Integer getIdSountrack() {
        return idSountrack;
    }

    public void setIdSountrack(Integer idSountrack) {
        this.idSountrack = idSountrack;
    }

    public String getSoundPicture() {
        return soundPicture;
    }

    public void setSoundPicture(String soundPicture) {
        this.soundPicture = soundPicture;
    }

    @XmlTransient
    public Collection<Song> getSongCollection() {
        return songCollection;
    }

    public void setSongCollection(Collection<Song> songCollection) {
        this.songCollection = songCollection;
    }

    @XmlTransient
    public Collection<Movie> getMovieCollection() {
        return movieCollection;
    }

    public void setMovieCollection(Collection<Movie> movieCollection) {
        this.movieCollection = movieCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSountrack != null ? idSountrack.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Soundtrack)) {
            return false;
        }
        Soundtrack other = (Soundtrack) object;
        if ((this.idSountrack == null && other.idSountrack != null) || (this.idSountrack != null && !this.idSountrack.equals(other.idSountrack))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Soundtrack[ idSountrack=" + idSountrack + " ]";
    }
    
}
